import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/1',
    name: 'routeName',
    component: () => import('../views/1'),
  },
  {
    path:'/cha/:da?',
    props:true,
    name: '查询',
    component: () => import('../views/AdminCoachCha.vue'),
  },
  {
    path: '/admincontainer',
    name: 'routeName',
    component: () => import('../views/AdminContainer.vue'),
  },
  {
    path: '/adminregister',
    name: '登录页面',
    meta:{
      title:'后台管理中心-登录',
    },
    component: () => import('../views/AdminLogin.vue'),
  },
{
  path: '/adminlogin',
  name: '登录页面',
  meta:{
    title:'后台管理中心-登录',
  },
  component: () => import('../views/AdminLogin.vue'),
},
{
  path: '/admin',
  meta:{
    title:'DrivingTestBook-后台管理中心',
  },
  component: () => import('../views/Admin.vue'),
  redirect:'/admin/index',
  children:[
  {
    path: 'index',
    name: 'routeName',
    meta:{
      title:'后台管理中心-首页',
    },
    component: () => import('../views/AdminIndex.vue'),
  },
  {
    path: 'carlogo',
    name: 'routeName',
    meta:{
      title:'后台管理中心-首页',
    },
    component: () => import('../views/AdminCarLogo.vue'),
  },
    {
      path: 'user',
      name: '后台管理中心-用户管理',
      meta:{
        title:'后台管理中心-用户管理',
      },
      component: () => import('../views/AdminUser.vue'),
    },
    {
      path: 'booking',
      name: 'routeName',
      component: () => import('../views/AdminBooking.vue'),
    },
      {
        path: 'order',
        name: '后台管理中心-用户管理',
        meta:{
          title:'后台管理中心-用户管理',
        },
        component: () => import('../views/AdminOrder.vue'),
      },
    {
      path: 'car',
      name: '后台管理中心-车商场',
      meta:{
        title:'后台管理中心-车商场',
      },
      component: () => import('../views/AdminCar.vue'),
    },
    {
      path: 'coach',
      name: '后台管理中心-教练管理',
      meta:{
        title:'后台管理中心-教练管理',
      },
      component: () => import('../views/AdminCoach.vue'),
    },
    {
      path: 'comment',
      name: '后台管理中心-评论管理',
      meta:{
        title:'后台管理中心-评论管理',
      },
      component: () => import('../views/AdminComment.vue'),
    },
    {
      path: 'drivingschool',
      name: '后台管理中心-驾校管理',
      meta:{
        title:'后台管理中心-驾校管理',
      },
      component: () => import('../views/AdminDrivingSchool.vue'),
    },
    {
      path: 'question',
      name: '后台管理中心-考试数据',
      meta:{
        title:'后台管理中心-试数据',
      },
      component: () => import('../views/AdminQuestion.vue'),
    },
    {
      path: 'manager',
      name: '后台管理中心-题库管理',
      meta:{
        title:'后台管理中心-题库管理',
      },
      component: () => import('../views/AdminManager.vue'),
    }
  ]
},
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
router.beforeEach((to, from, next) => {
  console.log('到哪去to:', to)
  console.log('当前from:', from)

  // 修改标签栏标题:
  document.title = to.meta.title

  next() // 放行: 允许路由跳转, 类似 express 的拦截器中间件
})
export default router
